package com.chen.admin.controller;


import com.chen.admin.common.Result;
import com.chen.admin.entity.CheckOutGuestInfo;
import com.chen.admin.service.CheckOutService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping("/admin")
public class CheckOutController {


    @Autowired
    private CheckOutService checkOutService;

    @PostMapping("/checkOut")
    public Result checkOut(@RequestBody CheckOutGuestInfo checkOutGuestInfo) {
        return checkOutService.checkOut(checkOutGuestInfo);
    }

    @GetMapping("/checkOutPageList")
    public Result<PageInfo> checkOutPageList(@RequestParam(defaultValue = "1") Integer pageNumber, @RequestParam(defaultValue = "10") Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
       List<CheckOutGuestInfo> checkOutGuestInfoList= checkOutService.checkOutPageList();
       return Result.success(new PageInfo(checkOutGuestInfoList));

    }
}
